Development of times gradually increases performance differences between a CPU (Central Processing Unit, central processing unit) and a memory. Various technologies are developed to reduce a delay of memory access, for example, use of a pipeline or multithreading. Data prefetching is also one of such technologies.
Data prefetching is a method of fetching in advance, from a memory before a processor accesses the memory, data A that is subsequently required and storing the data A into a Cache (cache). Then, when a CPU accesses A, the access can be directly performed because A already exists in the Cache, which reduces a delay caused by searching for A when the CPU accesses the memory.
Addresses used in instruction or data invoking by an application program during an execution process are all virtual addresses. In order to access a corresponding instruction or data from the memory, the virtual addresses need to be mapped to corresponding physical addresses. However, in a process of executing translation between a virtual address and a physical address, contiguous virtual pages may be mapped to contiguous physical pages, or may be mapped to noncontiguous physical pages.
When determining that cross-page prefetching needs to be performed, an existing prefetching device stops prefetching, which may prevent invalid cross-page prefetching when contiguous virtual pages are mapped to noncontiguous physical pages. However, 50% to 70% physical pages mapped to virtual pages are actually contiguous, that is, a determined prefetching address is valid. Based on a method in the prior art, when an invalid cross-page prefetching is prevented, a valid cross-page prefetching may also be prevented, which causes a low prefetching hit ratio of a prefetching device, and further reduces efficiency of memory access.